package com.myproject.jdbc;


import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisConnect {

    @Test
    public void test1(){
        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
        config.setMaxTotal(10);
        config.setMinIdle(5);

        //JedisPool jedisPool = new JedisPool(config,"118.89.68.96",6379);
        JedisPool jedisPool = new JedisPool(config,"118.89.68.96",6379,2000,"123456");
        Jedis jedis = jedisPool.getResource();
        jedis.auth("123456");
        String name = jedis.get("name");
        System.out.println(name);
        jedis.close();
        jedisPool.destroy();
    }

    public static void main(String[] args) {

        Jedis jedis = new Jedis("118.89.68.96",6379);
        jedis.auth("123456");
        System.out.println(jedis.get("name"));
        jedis.close();
    }

}
